package Test1;

public class TestDemo6 {
    public static void main(String[] args) {
        String str1 = "1.0.1";
        String str2 = "1";
        System.out.println(compare(str1, str2));
    }
    public static int compare (String version1, String version2) {
        // write code here
        int i = 0,m = version1.length();
        int j = 0,n = version2.length();
        while(i < m || j < n) {
            int a = 0,b = 0;
            while(i < m && version1.charAt(i) != '.') {
                a = a*10 + (version1.charAt(i++) - '0');
            }
            i++;
            while(j < n && version2.charAt(j) != '.') {
                b = b*10 + (version2.charAt(j++) - '0');
            }
            j++;
            if(a != b) return a > b ? 1:-1;
        }
        return 0;
    }
}
